package zhou.contest14;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class Read
 */
public class Read extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public Read() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		String evaluate=request.getParameter("evaluate");
		String message=request.getParameter("message");	
		
		if(evaluate!=""&&message!=""){	 //不等于 									       
			User user=new User();
			UserService us=new UserService();
			boolean result=false;
			try {
				result=us.evaluate(user, evaluate, message);
				
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();       
			}
			   if(result){
				response.sendRedirect("zhou_ArticleS.html");
			   }
			   else{
				response.sendRedirect("zhou_ArticleF.html");
			 }
			}
			else{
				response.sendRedirect("zhou_ArticleF.html");
		}	
		
		
		//response.getWriter().append("Served at: ").append(request.getContextPath());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
